Skip to content

fix(test): stabilize lifecycle, sleep, queue, and run edge cases#4660

Draft
NathanFlurry wants to merge 1 commit intobreak-up/reenable-gateway-url-coveragefrom
break-up/stabilize-driver-lifecycle-tests
Draft

fix(test): stabilize lifecycle, sleep, queue, and run edge cases#4660
NathanFlurry wants to merge 1 commit intobreak-up/reenable-gateway-url-coveragefrom
break-up/stabilize-driver-lifecycle-tests

Conversation

@NathanFlurry
Copy link
Copy Markdown
Member

Description

Please include a summary of the changes and the related issue. Please also include relevant motivation and context.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Copy link
Copy Markdown
Member Author

NathanFlurry commented Apr 14, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@claude
Copy link
Copy Markdown

claude bot commented Apr 14, 2026

PR Review: fix(test): stabilize lifecycle, sleep, queue, and run edge cases

Overview

This PR stabilizes a broad set of flaky driver tests by:

  • Replacing fixed waitFor delays with vi.waitFor polling
  • Relaxing exact count assertions where multiple cycles can occur
  • Making lifecycle tests tolerate inherent create/destroy race conditions
  • Introducing a lifecycle observer actor to verify events on destroyed actors
  • Using c.queue.send() directly instead of self-referencing via client
  • Fixing Response.json() compatibility across runtimes

The approach is sound overall. These changes reflect real non-determinism in the system rather than test implementation bugs.


Issues

isDynamicSandboxRuntime() is fragile and undocumented (inline-client.ts)

The process.cwd() === "/root" check is a platform-detection heuristic that will silently break if the sandbox working directory changes. The behavior divergence is significant: the sandbox path skips WebSocket entirely and uses direct action calls. This needs a comment explaining the constraint, and ideally should use an explicit environment variable or driver config flag instead.

destroyActor silently swallows all errors (actor-lifecycle.ts)

The final bare return at the end of the catch block swallows ALL unexpected errors from destroy(). The service_unavailable and destroy-race branches are intentional, but the catch-all fallthrough should throw err rather than silently returning, or have a comment explaining why every possible error is acceptable here.

Duplicate event listener in broadcast test (actor-sleep-db.ts)

Both connection.once("sleeping", ...) and connection.on("sleeping", ...) are registered for the same event. The on handler is redundant since the once handler already sets sleepingEventReceived = true, and the on listener leaks (never unsubscribed). Only once is needed.

instanceof errors.ActorAborted replaced with duck-typing without explanation (queue.ts, actor/instance/queue.ts)

Changing to error.group/code comparison is likely the right fix for cross-VM-context errors where instanceof fails, but there is no comment explaining why. This is non-obvious and will confuse future maintainers.


Minor Notes

  • resolveActorId returning null: When resolve() throws a destroy race error, downstream assertions are silently skipped. The outcome is still valid but a comment would clarify intent.
  • waitForConnectionOpen duck-typing: Manually typed rather than using the existing connection type. If the type is exported, prefer it.
  • Removed log line in run.ts: Dropping c.log.info for tick count is fine but will make debugging tick test failures harder.
  • lifecycle-hooks.ts API change: Moving connection params from .connect() to .getOrCreate(undefined, params) is a real API change; worth noting if it affects any public surface.
  • Sequential mode in actor-run.ts: Adding .sequential is correct but a brief comment on why would help future readers.

Positive Changes

  • The lifecycle observer pattern is a clean design for verifying lifecycle on actors that may be destroyed before assertions run.
  • triggerSleepTwice directly validates idempotency of the sleep flag within a single actor turn.
  • c.queue.send() replacing the self-client pattern is the correct fix.
  • Timeout increases and vi.waitFor polling are the right stabilization approach for async tests.

Generated with Claude Code

@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from ecf268c to 4c4e267 Compare April 15, 2026 02:40
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from dcb82e8 to 1d9c571 Compare April 15, 2026 02:40
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from 4c4e267 to e823f78 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from 1d9c571 to 8e50d57 Compare April 15, 2026 02:50
@NathanFlurry NathanFlurry marked this pull request as ready for review April 15, 2026 02:57
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from 8e50d57 to f2052c1 Compare April 15, 2026 03:07
@NathanFlurry NathanFlurry marked this pull request as draft April 15, 2026 03:17
@NathanFlurry NathanFlurry force-pushed the break-up/reenable-gateway-url-coverage branch from e823f78 to 83bf5c0 Compare April 15, 2026 06:55
@NathanFlurry NathanFlurry force-pushed the break-up/stabilize-driver-lifecycle-tests branch from f2052c1 to 5aeb5f4 Compare April 15, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant